﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NetFramework.Diagnostics
{
    public static class Ensure
    {
        /// <summary>
        /// Makes sure a given argument is not null.
        /// </summary>
        /// <typeparam name="T">Type of the argument.</typeparam>
        /// <param name="argument">The submitted parameter value.</param>
        /// <param name="argumentName">The name of the argument.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="argument"/>
        /// is a null reference.</exception>
        public static void ArgumentNotNull<T>(T argument, string argumentName) where T : class
        {
            if (argument == null) throw new ArgumentNullException(argumentName);
        }

        public static void IstNull<T>(T obj, string objectName) where T : class
        {
            if (obj == null) throw new NullReferenceException(objectName);
        }

        public static void IsNotEmpty(string obj, string message)
        {
            if (string.IsNullOrEmpty(obj)) throw new ArgumentException(message);
        }

        public static void IsNotNull(string argumentName, object argument, string message, params object[] parameters)
        {
            if (argument == null)
            {
                throw new ArgumentNullException(argumentName, string.Format(message, parameters));
            }
        }
    }
}
